home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 022 / lemacs / estruct.h < prev    next >
C/C++ Source or Header  |  1995-03-17  |  12KB  |  259 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.6
  3.  
  4.             written by Dave G. Conroy
  5.             modified by Steve Wilhite, George Jones
  6.             greatly modified by Daniel Lawrence
  7. */
  8.  
  9. /*
  10.  * Define BRAINDAMAGE if your compilation environment is too stupid
  11.  * to define it's own unique symbols.  Then take care of what the
  12.  * environment should have done for you.  Fred Fish 10-May-86
  13.  */
  14.  
  15. #ifdef BRAINDAMAGE
  16. #undef    LATTICE        /* don't use their definitions...use ours    */
  17. #undef    MSDOS
  18. #undef    CPM
  19. #endif
  20.  
  21. /*    Machine/OS definitions            */
  22.  
  23. #ifdef BRAINDAMAGE
  24. #define AMIGA   1                       /* AmigaDOS            */
  25. #define ST520   0                       /* ST520, TOS                   */
  26. #define MSDOS   0                       /* MS-DOS                       */
  27. #define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
  28. #define    BSD    0            /* also needed for BSD 4.2    */
  29. #define VMS     0                       /* VAX/VMS                      */
  30. #define CPM     0                       /* CP/M-86                      */
  31. #endif
  32.  
  33. /*    Compiler definitions            */
  34. #ifdef BRAINDAMAGE
  35. #define MWC86   0    /* marc williams compiler */
  36. #define    LATTICE    0    /* either lattice compiler */
  37. #define    LAT2    0    /* Lattice 2.15 */
  38. #define    LAT3    0    /* Lattice 3.0 */
  39. #define    AZTEC    0    /* Aztec C 3.20e */
  40. #endif
  41.  
  42. #ifdef LATTICE
  43. #undef LATTICE
  44. #define LATTICE 1    /* -DLATTICE is not the same as -DLATTICE=1 ??? */
  45. #endif
  46.  
  47. #ifdef MANX
  48. #define AZTEC    1
  49. #endif
  50.  
  51. /*    Terminal Output definitions        */
  52.  
  53. #define ANSI    1            /* ansi escape sequences    */
  54. #define    HP150    0            /* HP150 screen driver        */
  55. #define    VMSVT    0            /* various VMS terminal entries    */
  56. #define VT52    0                       /* VT52 terminal (Zenith).      */
  57. #define VT100   0                       /* Handle VT100 style keypad.   */
  58. #define LK201   0                       /* Handle LK201 style keypad.   */
  59. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  60. #define TERMCAP 0                       /* Use TERMCAP                  */
  61.  
  62. /*    Configuration options    */
  63.  
  64. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  65. #define    NFWORD    1    /* forward word jumps to begining of word    */
  66. #define    CLRMSG    0    /* space clears the message line with no insert    */
  67. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  68. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  69. #define    REVSTA    1    /* Status line appears in reverse video        */
  70.  
  71. /*    System dependant library redefinitions    */
  72.  
  73. #if    MSDOS & AZTEC
  74. #undef    fputc
  75. #undef    fgetc
  76. #define    fputc    aputc
  77. #define    fgetc    agetc
  78. #endif
  79.  
  80. /*    internal constants    */
  81.  
  82. #define    NBINDS    200            /* max # of bound keys        */
  83. #define NFILEN  80                      /* # of bytes, file name        */
  84. #define NBUFN   16                      /* # of bytes, buffer name      */
  85. #define NLINE   256                     /* # of bytes, line             */
  86. #define    NSTRING    256            /* # of bytes, string buffers    */
  87. #define NKBDM   256                     /* # of strokes, keyboard macro */
  88. #define NPAT    80                      /* # of bytes, pattern          */
  89. #define HUGE    1000                    /* Huge number                  */
  90. #define    NLOCKS    100            /* max # of file locks active    */
  91.  
  92. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  93. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  94. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  95. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  96. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  97. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  98.  
  99. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  100. #define META    0x0200                  /* Meta flag, or'ed in          */
  101. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  102. #define    SPEC    0x0800            /* special key (function keys)    */
  103.  
  104. #define FALSE   0                       /* False, no, bad, etc.         */
  105. #define TRUE    1                       /* True, yes, good, etc.        */
  106. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  107.  
  108. #define FIOSUC  0                       /* File I/O, success.           */
  109. #define FIOFNF  1                       /* File I/O, file not found.    */
  110. #define FIOEOF  2                       /* File I/O, end of file.       */
  111. #define FIOERR  3                       /* File I/O, error.             */
  112. #define    FIOLNG    4            /*line longer than allowed len    */
  113.  
  114. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  115. #define CFKILL  0x0002                  /* Last command was a kill      */
  116.  
  117. #define    BELL    0x07            /* a bell character        */
  118. #define    TAB    0x09            /* a tab character        */
  119.  
  120. /*
  121.  * There is a window structure allocated for every active display window. The
  122.  * windows are kept in a big list, in top to bottom screen order, with the
  123.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  124.  * The flag field contains some bits that are set by commands to guide
  125.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  126.  * the full blown redisplay is just too expensive to run for every input
  127.  * character.
  128.  */
  129. typedef struct  WINDOW {
  130.         struct  WINDOW *w_wndp;         /* Next window                  */
  131.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  132.         struct  LINE *w_linep;          /* Top line in the window       */
  133.         struct  LINE *w_dotp;           /* Line containing "."          */
  134.         short   w_doto;                 /* Byte offset for "."          */
  135.         struct  LINE *w_markp;          /* Line containing "mark"       */
  136.         short   w_marko;                /* Byte offset for "mark"       */
  137.         char    w_toprow;               /* Origin 0 top row of window   */
  138.         char    w_ntrows;               /* # of rows of text in window  */
  139.         char    w_force;                /* If NZ, forcing row.          */
  140.         char    w_flag;                 /* Flags.                       */
  141. }       WINDOW;
  142.  
  143. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  144. #define WFMOVE  0x02                    /* Movement from line to line   */
  145. #define WFEDIT  0x04                    /* Editing within a line        */
  146. #define WFHARD  0x08                    /* Better to a full display     */
  147. #define WFMODE  0x10                    /* Update mode line.            */
  148.  
  149. /*
  150.  * Text is kept in buffers. A buffer header, described below, exists for every
  151.  * buffer in the system. The buffers are kept in a big list, so that commands
  152.  * that search for a buffer by name can find the buffer header. There is a
  153.  * safe store for the dot and mark in the header, but this is only valid if
  154.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  155.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  156.  * the header line in "b_linep".
  157.  *     Buffers may be "Inactive" which means the files accosiated with them
  158.  * have not been read in yet. These get read in at "use buffer" time.
  159.  */
  160. typedef struct  BUFFER {
  161.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  162.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  163.         short   b_doto;                 /* Offset of "." in above LINE  */
  164.         struct  LINE *b_markp;          /* The same as the above two,   */
  165.         short   b_marko;                /* but for the "mark"           */
  166.         struct  LINE *b_linep;          /* Link to the header LINE      */
  167.     char    b_active;        /* window activated flag    */
  168.         char    b_nwnd;                 /* Count of windows on buffer   */
  169.         char    b_flag;                 /* Flags                        */
  170.     char    b_mode;            /* editor mode of this buffer    */
  171.         char    b_fname[NFILEN];        /* File name                    */
  172.         char    b_bname[NBUFN];         /* Buffer name                  */
  173. }       BUFFER;
  174.  
  175. #define BFTEMP  0x01                    /* Internal temporary buffer    */
  176. #define BFCHG   0x02                    /* Changed since last write     */
  177.  
  178. /*    mode flags    */
  179. #define    NUMMODES    6        /* # of defined modes        */
  180.  
  181. #define    MDWRAP    0x0001            /* word wrap            */
  182. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  183. #define    MDSPELL    0x0004            /* spell error parcing        */
  184. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  185. #define    MDVIEW    0x0010            /* read-only buffer        */
  186. #define MDOVER    0x0020            /* overwrite mode        */
  187.  
  188. /*
  189.  * The starting position of a region, and the size of the region in
  190.  * characters, is kept in a region structure.  Used by the region commands.
  191.  */
  192. typedef struct  {
  193.         struct  LINE *r_linep;          /* Origin LINE address.         */
  194.         short   r_offset;               /* Origin LINE offset.          */
  195.         short   r_size;                 /* Length in characters.        */
  196. }       REGION;
  197.  
  198. /*
  199.  * All text is kept in circularly linked lists of "LINE" structures. These
  200.  * begin at the header line (which is the blank line beyond the end of the
  201.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  202.  * number of bytes in the line (the "used" size), the size of the text array,
  203.  * and the text. The end of line is not stored as a byte; it's implied. Future
  204.  * additions will include update hints, and a list of marks into the line.
  205.  */
  206. typedef struct  LINE {
  207.         struct  LINE *l_fp;             /* Link to the next line        */
  208.         struct  LINE *l_bp;             /* Link to the previous line    */
  209.         short   l_size;                 /* Allocated size               */
  210.         short   l_used;                 /* Used size                    */
  211.         char    l_text[1];              /* A bunch of characters.       */
  212. }       LINE;
  213.  
  214. #define lforw(lp)       ((lp)->l_fp)
  215. #define lback(lp)       ((lp)->l_bp)
  216. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  217. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  218. #define llength(lp)     ((lp)->l_used)
  219.  
  220. /*
  221.  * The editor communicates with the display using a high level interface. A
  222.  * "TERM" structure holds useful variables, and indirect pointers to routines
  223.  * that do useful operations. The low level get and put routines are here too.
  224.  * This lets a terminal, in addition to having non standard commands, have
  225.  * funny get and put character code too. The calls might get changed to
  226.  * "termp->t_field" style in the future, to make it possible to run more than
  227.  * one terminal type.
  228.  */
  229. typedef struct  {
  230.         short   t_nrow;                 /* Number of rows.              */
  231.         short   t_ncol;                 /* Number of columns.           */
  232.     short    t_margin;        /* min margin for extended lines*/
  233.     short    t_scrsiz;        /* size of scroll region "    */
  234.         int     (*t_open)();            /* Open terminal at the start.  */
  235.         int     (*t_close)();           /* Close terminal at end.       */
  236.         int     (*t_getchar)();         /* Get character from keyboard. */
  237.         int     (*t_putchar)();         /* Put character to display.    */
  238.         int     (*t_flush)();           /* Flush output buffers.        */
  239.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  240.         int     (*t_eeol)();            /* Erase to end of line.        */
  241.         int     (*t_eeop)();            /* Erase to end of page.        */
  242.         int     (*t_beep)();            /* Beep.                        */
  243.     int    (*t_rev)();        /* set reverse video state    */
  244. }       TERM;
  245.  
  246. /*    structure for the table of initial key bindings        */
  247.  
  248. typedef struct  {
  249.         short   k_code;                 /* Key code                     */
  250.         int     (*k_fp)();              /* Routine to handle it         */
  251. }       KEYTAB;
  252.  
  253. /*    structure for the name binding table        */
  254.  
  255. typedef struct {
  256.     char *n_name;        /* name of function key */
  257.     int (*n_func)();    /* function name is bound to */
  258. }    NBIND;
  259.